package com.glidecast.common
{
	import flash.utils.ByteArray;
	import flash.display.*;
	import flash.geom.*;
	
	public class gcUtil
	{

		static public function clone(orjObj:Object):Object
		{
			var copyObj:ByteArray = new ByteArray();
			copyObj.writeObject(orjObj);
			copyObj.position = 0;
			return(copyObj.readObject());
		}
		static public function cloneDisplayObject(target:DisplayObject ):IBitmapDrawable
		{
			var bitmapClone:Bitmap = null;
			var bitmapData:BitmapData = new BitmapData(target.width, target.height, true, 0x00000000);
			bitmapData.draw(target);
			bitmapClone = new Bitmap(bitmapData);
			bitmapClone.smoothing = true;    
			return bitmapClone;
		}
		static public function cloneSprite(source:Sprite):Sprite
		{
			var Sprite2:Sprite = new Sprite();
			
			Sprite2.transform = source.transform;
			Sprite2.filters = source.filters;
			Sprite2.cacheAsBitmap = source.cacheAsBitmap;
			Sprite2.opaqueBackground = source.opaqueBackground;
			if (source.scale9Grid)
			{
				var rect:Rectangle = source.scale9Grid;
				rect.x /= 20, rect.y /= 20, rect.width /= 20, rect.height /= 20;
				Sprite2.scale9Grid = rect;
			}
			return Sprite2;
		}
	}
}
